package com.ruoyi.artworks.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.artworks.dao.ArtWorksStuTypeDao;
import com.ruoyi.artworks.domain.ArtworkType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.artworks.domain.Artworks;
import com.ruoyi.artworks.service.IArtworksService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 校区作品管理Controller
 * 
 * @author hyl
 * @date 2025-06-19
 */
@RestController
@RequestMapping("/artworks/artworks")
public class ArtworksController extends BaseController
{
    @Autowired
    private IArtworksService artworksService;

    /**
     * 查询校区作品管理列表
     */
    @PreAuthorize("@ss.hasPermi('artworks:artworks:list')")
    @GetMapping("/list")
    public TableDataInfo list(ArtWorksStuTypeDao artWorksStuTypeDao)
    {
        startPage();
        List<ArtWorksStuTypeDao> list = artworksService.selectArtworksList(artWorksStuTypeDao);
        return getDataTable(list);
    }

    /**
     * 导出校区作品管理列表
     */
//    @PreAuthorize("@ss.hasPermi('artworks:artworks:export')")
//    @Log(title = "校区作品管理", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, Artworks artworks)
//    {
//        List<Artworks> list = artworksService.selectArtworksList(artworks);
//        ExcelUtil<Artworks> util = new ExcelUtil<Artworks>(Artworks.class);
//        util.exportExcel(response, list, "校区作品管理数据");
//    }

    /**
     * 获取校区作品管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('artworks:artworks:query')")
    @GetMapping(value = "/{artworksId}")
    public AjaxResult getInfo(@PathVariable("artworksId") Long artworksId)
    {
        return success(artworksService.selectArtworksByArtworksId(artworksId));
    }

    /**
     * 新增校区作品管理
     */
    @PreAuthorize("@ss.hasPermi('artworks:artworks:add')")
    @Log(title = "校区作品管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Artworks artworks)
    {
        return toAjax(artworksService.insertArtworks(artworks));
    }

    /**
     * 修改校区作品管理
     */
    @PreAuthorize("@ss.hasPermi('artworks:artworks:edit')")
    @Log(title = "校区作品管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Artworks artworks)
    {
        return toAjax(artworksService.updateArtworks(artworks));
    }

    /**
     * 删除校区作品管理
     */
    @PreAuthorize("@ss.hasPermi('artworks:artworks:remove')")
    @Log(title = "校区作品管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{artworksIds}")
    public AjaxResult remove(@PathVariable Long[] artworksIds)
    {
        return toAjax(artworksService.deleteArtworksByArtworksIds(artworksIds));
    }

//    查询所有作品类型
    @GetMapping("/selectAllArtType")
    public AjaxResult selectAllArtType(ArtworkType artworkType){
        List<ArtworkType> typeList = artworksService.selectAllArtType(artworkType);
        return AjaxResult.success("typeList",typeList);
    }
}
